﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@

@using NewLife;
@using NewLife.Cube
@using XCode
@{
    var entity = Model as IEntity;
    var set = ViewBag.PageSetting as PageSetting;

    var rv = entity.GetRouteKey();
}
@if (set.IsReadOnly)
{
    if (this.Has(PermissionFlags.Detail))
    {
        <a href="@Url.Action("Detail", rv)" class="p-0 pe-2  bg-hover-light" title="查看">
            <i class="fas fa-file-alt text-primary fs-4"></i>
        </a>
    }
}
else if (this.Has(PermissionFlags.Update))
{
    <a href="@Url.Action("Edit", rv)" class="p-0 pe-2 bg-hover-light editcell" title="编辑">
        <i class="fas fa-pen-alt text-info fs-4"></i>
    </a>
}
else if (this.Has(PermissionFlags.Detail))
{
    <a href="@Url.Action("Detail", rv)" class="p-0 pe-2 bg-hover-light" title="查看">
        <i class="fas fa-file-alt text-info fs-4"></i>
    </a>
}
@if (this.Has(PermissionFlags.Delete))
{
    var fact = ViewBag.Factory as IEntityFactory;
    var fi = (fact == null || fact.Fields == null) ? null : fact.Fields.FirstOrDefault(e => e.Name.EqualIgnoreCase("Deleted", "IsDelete", "IsDeleted"));
    if (fi != null && fi.Type == typeof(Boolean) && (Boolean)entity[fi.Name])
    {
        <a title="恢复" class="p-0 pe-1 bg-hover-light swal_tip" data-url="@Url.Action("Delete", rv)" data-type="warning" data-title="确认恢复？">
            <i class="fas fa-rev text-warning fs-4"></i>
        </a>
    }
    else
    {
        <a title="删除" class="p-0 pe-1 bg-hover-light swal_tip" data-url="@Url.Action("Delete", rv)" data-type="error" data-title="确认删除？">
            <i class="fas fa-trash text-danger fs-4"></i>
        </a>
    }
}
